//	processTable.h 

//#include "copyright.h"

#include "addrspace.h"
#include "bitmap.h"
#include "synch.h"

#define MAX_THREAD_NUM 512	// the maximum number of threads in a process

class ProcessTableEntry {
  public:
    ProcessTableEntry(AddrSpace *space);	// Create an entry in the process table, 
												// which maps the addrspace to the spaceId
	~ProcessTableEntry();
	
	int CreateThread(int stackNum);	// create a new thread;
	void SetStackInfo(int threadId, int stackNum);
	int ExitThread(int threadId);	// exit a thread;
	bool HasNoThread() { return activeNum == 0; }	// check whether there is no thread
													// in this process
	unsigned int activeNum;	// total acitve thread number in the process
	unsigned int inactiveNum; // total inactive thread number in the process
	
 private:
	AddrSpace *addrspace;
	Lock *entryLock;
	BitMap *threadMap;
	int threadInfo[MAX_THREAD_NUM];
};
